<include file="Common:header" />
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{:U(MODULE_NAME.'/Index/info')}">首页</a> &raquo; 模块管理
    </div>
    <!--面包屑导航 结束-->

        <div id='warp' class=add-app>
            <a href="{:U(MODULE_NAME.'/Access/addNode')}"><i class="fa fa-plus"></i> 添加模块</a>
            <foreach name='node' item='app'>
                <div class="app">
                    <p>
                        <strong>{$app.title}</strong>&nbsp;&nbsp;[<a
                            href="{:U(MODULE_NAME.'/Access/editNode',array('id'=>$app['id']))}">修改</a>]&nbsp;&nbsp;[<a
                            href="javascript:;" onclick="delNodes({$app['id']});">删除</a>]&nbsp;&nbsp;[<a
                            href="{:U(MODULE_NAME.'/Access/addNode',array('pid'=>$app['id'],'level'=>2))}">添加控制器</a>]

                    </p>
                    <foreach name='app.child' item='action'>
                        <dl>
                            <dt>
                                <strong>{$action.title}</strong>&nbsp;&nbsp;[<a
                                    href="{:U(MODULE_NAME.'/Access/editNode',array('id'=>$action['id']))}">修改</a>]&nbsp;&nbsp;[<a
                                    href="javascript:;" onclick="delNodes({$action['id']});">删除</a>]&nbsp;&nbsp;[<a
                                    href="{:U(MODULE_NAME.'/Access/addNode',array('pid'=>$action['id'],'level'=>3))}">添加方法</a>]
                            </dt>
                        </dl>
                        <foreach name='action.child' item='child'>
                            <dd><!--<input type="text" name="sort" style="width: 15px; height: 15px" value="{$child.sort}" onchange="changeBynode(this,{$child['id']})" >-->
                                <span>{$child.title}</span> &nbsp;&nbsp;[<a
                                    href="{:U(MODULE_NAME.'/Access/editNode',array('id'=>$child['id']))}">修改</a>]&nbsp;&nbsp;[<a
                                    href="javascript:;" onclick="delNodes({$child['id']});">删除</a>]
                            </dd>
                        </foreach> </foreach>
                </div>
            </foreach>
        </div>
</body>
</html>
<script type="text/javascript">
    //异步删除
    function delNodes(id){
        //layer询问框
        layer.confirm('您确定要进行删除操作？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:U(MODULE_NAME."/Access/deleteNode")}',{'id':id},function(data){
                if(data.status==1){
                    layer.msg(data.info);
                    location.href="{:U(MODULE_NAME.'/Access/node')}";
                }else{
                    layer.msg(data.info);
                }
            });
        });
    }


    //异步排序修改
    function changeBynode(obj,id){
        var sort = $(obj).val();
        $.post("{:U(MODULE_NAME.'/Access/changenode')}",{'sort':sort,'id':id},function(data){
            if(data.status==1){
                layer.alert(data.info, {icon: 6});
                $('.layui-layer-btn .layui-layer-btn0').click(function(){
                    location.href=location.href;
                });
                //location.href=location.href;
            }else{
                layer.alert(data.info, {icon: 5});
            }
        });
    }

</script>